package com.itheima.test1;

public class Tickets implements Runnable {
    private int tickets;

    public Tickets() {
        this.tickets = 100;
    }

    @Override
    public void run() {
        while (true){
            synchronized (this){
                if(tickets==0){
                    break;
                }else {
                    tickets--;
                    System.out.println(Thread.currentThread().getName()+"正在卖票,还剩"+tickets+"张");
                }
            }
        }
    }
}
